import DataItemModel from "../../../cfw/mvc/DataItemModel";
import { BathItemModelEnum } from "../../../public/GameEnumConfig";
import { ItemState } from "../../../cfw/tools/Define";
import User from "../../db/User";
import Player from "../../player/Player";
/**
* 浴室用具
**/
export default class BathItemModel extends DataItemModel {

	static CLASS_NAME: string = 'BathItemModel'

	init(id, data) {
		super.init(id, data)
		this.state = User.instance().getBathItemState(this.ID)
	}
	// icon
	getIcon() {
		return 'texture/bathitem/' + this.data[BathItemModelEnum.icon]
	}
	// 消费道具
	getCostItem() {
		return this.data[BathItemModelEnum.costItem]
	}
	// 图标缩放
	getScale() {
		return this.data[BathItemModelEnum.scale]
	}
	// 索引
	getIndex() {
		return this.data[BathItemModelEnum.index]
	}
	// 清洁度
	getCleanNum() {
		return this.data[BathItemModelEnum.cleanNum]
	}


	needBuy() {
		let cost: number[] = this.getCostItem()
		return cost.length > 0 && this.getState() != ItemState.GOT
	}
	getOpenLevel() {
		let num = this.data[BathItemModelEnum.adge]
		return num ? num : 0
	}
	setState(s: ItemState) {
		super.setState(s)
		//cc.log(' setState s ', s, ' ID ', this.ID)
		User.instance().setBathItemState(this.ID, s)
	}
	isOpen() {
		return Player.instance().getLevel() >= this.getOpenLevel()
	}

}